fix(desktop): show local diff stats in v1 workspace hover card#3881
Conversation
The v1 workspace hover modal was rendering pr.additions/pr.deletions from the GitHub PR snapshot, while the sidebar row showed local working-tree stats — so the two surfaces could disagree and the modal LOC appeared to flicker as PR data refetched. Centralize via a new useLocalDiffStats hook (wraps useGitChangesStatus) and use it in both surfaces. Drop the PR-stats fallback in the sidebar row so before-hover and after-hover stay consistent.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe changes refactor how diff statistics (additions/deletions counts) flow through WorkspaceSidebar components. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsx`:
- Around line 173-180: The hover card currently only renders diffStats inside a
branch gated by PR presence, so local workspace +/- counts (diffStats) are
hidden for non-PR workspaces; update the WorkspaceHoverCard to render diffStats
unconditionally when available (remove or move the PR-specific conditional that
surrounds the diff-stats block), ensuring the JSX that references diffStats (the
<div> showing +{diffStats.additions} and -{diffStats.deletions}) is evaluated
for regular workspaces as well as PR workspaces; keep existing null/undefined
checks on diffStats but decouple it from the "pr" branch so local diffs show in
the no-PR hover modal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2a3bb0a7-a544-4766-8944-27a2d3045f2f
📒 Files selected for processing (6)
apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsapps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsxapps/desktop/src/renderer/screens/main/hooks/index.tsapps/desktop/src/renderer/screens/main/hooks/useLocalDiffStats/index.tsapps/desktop/src/renderer/screens/main/hooks/useLocalDiffStats/useLocalDiffStats.ts
Lift the LOC source up to the parent (WorkspaceListItem already computes it for the inline +/-) and pass the same value into the hover card, so the modal renders whatever it's handed instead of fetching its own copy. Also render the diff stats in the no-PR and no-remote branches — they were previously gated behind PR presence. Reverts the worktreePath addition to getWorktreeInfo since the hover card no longer needs it.
… view The workspace list row was reading additions/deletions from the GitHub PR snapshot, which can drift from the local working tree and refetches on its own cadence — values appeared to flicker. List rows don't need LOC, so drop the display (and the now-unused githubStatus prefetch).
The useLocalDiffStats hook was only called in one place; the other three imports were just for the LocalDiffStats type on a prop. Inline the useMemo back into WorkspaceListItem and use a structural type on the prop instead — drops the hook file and its index export.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Already integrated, superseded by current versions, or net-empty in this fork: superset-sh#3881 superset-sh#3887 superset-sh#3917 superset-sh#3925 superset-sh#3940 superset-sh#3956 superset-sh#3961 superset-sh#3974 superset-sh#4017 superset-sh#4048 superset-sh#4049 superset-sh#4055 superset-sh#4063 superset-sh#4070 superset-sh#4092 superset-sh#4110 superset-sh#4138 superset-sh#4159 superset-sh#4163 superset-sh#4164 superset-sh#4209 superset-sh#4210 superset-sh#4249 superset-sh#4349 superset-sh#4405 superset-sh#4462 superset-sh#4464 superset-sh#4494 superset-sh#4495 superset-sh#4500 superset-sh#4535 superset-sh#4541 superset-sh#4566 superset-sh#4580 superset-sh#4589 superset-sh#4593 superset-sh#4603 superset-sh#4637 superset-sh#4642 superset-sh#4655 superset-sh#4657 superset-sh#4659 superset-sh#4685 superset-sh#4692 superset-sh#4745 superset-sh#4789 superset-sh#4797 superset-sh#4824 superset-sh#4835 superset-sh#4847 superset-sh#4885 superset-sh#4896.
Summary
pr.additions/pr.deletionsfrom the GitHub PR snapshot while the sidebar row showed local working-tree stats — the two surfaces disagreed and the modal LOC appeared to flicker as PR data refetched.useLocalDiffStatshook (wrapsuseGitChangesStatus) and use it in both the sidebar row and the hover modal.getWorktreeInfonow also returnsworktreePathso the hover card can drive the local git query without prop-drilling.Workspace list view (
WorkspaceRow) is intentionally left alone — it shows closed worktrees too, so any change there needs a separate think-through.Test plan
+/-matches the inline+/-on the row and stays stable across refetches.git:changedinvalidation.Summary by cubic
Show local working‑tree diff stats in the v1 workspace hover card to match the sidebar and eliminate LOC flicker. Compute the stats once in
WorkspaceListItemand pass them into the hover card; remove PR-based LOC from the workspace list view.Bug Fixes
+/-counts, matching the sidebar.Refactors
WorkspaceListItem(removeduseLocalDiffStats) and passeddiffStatsto the hover card, collapsed item, and context menu.worktreePathaddition togetWorktreeInfo.Written for commit 15546ab. Summary will update on new commits. Review in cubic
Summary by CodeRabbit